package com.study.netty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;

public class FilesWalkTreeTest {

    private static final Logger log= LoggerFactory.getLogger(FilesWalkTreeTest.class);
    public static void main(String[] args) throws IOException {
        Files.walkFileTree(Paths.get("E://"), new FileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                log.info("preVisitDirectory:{}:{}",dir.getFileName(),attrs);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                log.info("visitFile:{}:{}",file.getFileName(),attrs);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                log.info("visitFileFailed:{}:{}",file.getFileName(),exc);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                log.info("visitFileFailed:{}:{}",dir.getFileName(),exc);
                return FileVisitResult.CONTINUE;
            }
        });
    }
}
